package com.zsj.hello.util;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author https://gitee.com/zhengshengjun
 * @date 2023/8/29.
 *
 * 用来连接工厂创建信道的工具类
 */
public class RabbimqFactoryUtil {

    public static Channel getRabbitMQChannel() throws IOException, TimeoutException {
        //链接rabbitmq 队列
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("127.0.0.1");
        factory.setUsername("zsj");
        factory.setPassword("zsj20001125");
        //建立连接
        Connection connection = factory.newConnection();
        //信道
        return connection.createChannel();
    }
}
